/*
 * @Author: 肖芬芳 1911683843@qq.com
 * @Date: 2022-09-23 16:21:30
 * @LastEditors: 肖芬芳 1911683843@qq.com
 * @LastEditTime: 2022-12-02 15:10:42
 * @FilePath: \node_studyc:\Users\Administrator\Desktop\vite-project\src\views\system\role\api\roleServiceApi.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { ServerResponse } from '@/util/base/ServerResponse'
import { Request } from '@/util/http/axios'
import { RoleListVo } from '../Vo/roleVo'
import { SearchList } from '../params/searchParams'
import {roleParams,statusParams} from "../params/searchParams"

export default class RoleServiceApi {
  async getRoleList (searchList: SearchList): Promise<ServerResponse<RoleListVo>> {
    const res = await Request.post<ServerResponse<RoleListVo>, SearchList>(
      '/role/list',
      searchList)
    return res.data
  }

  async addRole (roleParams:roleParams): Promise<ServerResponse<RoleListVo>> {
    const res = await Request.post<ServerResponse<RoleListVo>, roleParams>(
      '/role/add',
      roleParams)
    return res.data
  }

  async changeStatus (statusParams:statusParams): Promise<ServerResponse<RoleListVo>> {
    const res = await Request.post<ServerResponse<RoleListVo>, statusParams>(
      '/role/changeStatus',
      statusParams)
    return res.data
  }

  // 获取角色详情
  async detail(id:string):Promise<ServerResponse<RoleListVo>>{
    const res = await Request.get<ServerResponse<RoleListVo>, string>(
      '/role/detail/'+id+'')
    return res.data
  }

  // 编辑角色
  async modifyRole (roleParams:roleParams): Promise<ServerResponse<RoleListVo>> {
    const res = await Request.post<ServerResponse<RoleListVo>, roleParams>(
      '/role/modify',
      roleParams)
    return res.data
  }

  // 删除权限
  async deleteRight(roleId:string,rightId:string):Promise<ServerResponse<RoleListVo>> {
    const res = await Request.delete<ServerResponse<RoleListVo>, object>(
      '/role/'+roleId+'/right/'+rightId+'')
    return res.data
  }

  // 获取权限列表
  async getRightList():Promise<ServerResponse<RoleListVo>> {
    const res = await Request.get<ServerResponse<RoleListVo>, object>(
      '/role/getRightList')
    return res.data
  }
}